package cn.jh.smartos.adapter

import android.content.Intent
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import cn.jh.smartos.App
import cn.jh.smartos.R

/**
 * Created by pjh on 18/3/14.
 */
class MsgListAdapter : RecyclerView.Adapter<MsgListAdapter.ViewHolder>() {

    private var arrList = arrayListOf<String>()

    fun setData(list: ArrayList<String>?){
        if (list==null){
            return
        }
        arrList.clear()
        arrList.addAll(list)
        notifyDataSetChanged()
    }
    override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder {

        val view = View.inflate(App.context, R.layout.item_socket_list, null)
        return ViewHolder(view)
    }

    override fun getItemCount(): Int {
        return arrList.size
    }

    override fun onBindViewHolder(holder: ViewHolder?, position: Int) {
        val socketItem = arrList.get(position)
        val ip = holder?.itemView?.findViewById<TextView>(R.id.tv_ip)
        val msg = holder?.itemView?.findViewById<TextView>(R.id.tv_msg)
        ip?.text=socketItem
        holder?.itemView?.setOnClickListener {

        }



    }


    inner class ViewHolder(itemView: View?) : RecyclerView.ViewHolder(itemView) {

    }
}